package libs;


/**
 *              This class represents a seminar.
 * 
 * @author      Jan Papousek
 * @version     2009-03-02
 */
public class Seminar {

    /**
     *          Number of the seminar group.
     */
    private int number;

    /**
     *          Subject of the seminar group.
     */
    private Subject subject;


    /**
     * @param   subject     The subject of the seminar group.
     * @param   number      The number of the seminar group.
     * @throws  NullPointerException if the subject is null.
     * @throws  IllegalArgumentException if the number is <= 0.
     */
    public Seminar (Subject subject, int number) {
        if (subject == null) {
            throw new NullPointerException("The argument 'subject' is null.");
        }
        if (number <=  0) {
            throw new IllegalArgumentException("The number of the seminar group is <= 0.");
        }
        this.number = number;
        this.subject = subject;
    }

    /**
     *          It returns the seminar group number.
     * @return  Seminar group number.
     */
    public int getNumber () {
        return number;
    }

    /**
     *          It returns the subject of the seminar group.
     * @return  The subject.
     */
    public Subject getSubject () {
        return subject;
    }

    /**
     *          The seminar are the same if their number and subject are the same.
     */
    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Seminar)) {
            return false;
        }
        Seminar sem = (Seminar)o;
        return (
                (sem.getNumber() == this.getNumber())
                &&
                (sem.getSubject().equals(sem.getSubject()))
               );
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + this.number;
        hash = 37 * hash + (this.subject != null ? this.subject.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return Integer.toString(number);
    }

}
